<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <div th:include="public/layout::header('登陆')" th:remove="tag"></div>
    <link href="/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
</head>
<body>
<input type="hidden" id="TenantId" name="TenantId" value="" />
<div class="header"></div>
<div class="loginWraper">
    <div id="loginform" class="loginBox">
        <form class="form form-horizontal" action="/user/login" id="form-admin-login" method="post">
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <input  name="name" type="text" placeholder="账户" class="input-text size-L"/>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
                <div class="formControls col-xs-8">
                    <input name="password" type="password" placeholder="密码" class="input-text size-L"/>
                </div>
            </div>
            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <input name="code" class="input-text size-L" type="text" placeholder="验证码" onblur="if(this.value==''){this.value='验证码:'}" onclick="if(this.value=='验证码:'){this.value='';}" value="验证码:" style="width:150px;"/>
                    <img src="/kaptcha/get?" onclick="this.src=this.src+Math.random();"/>
                </div>
            </div>
            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <label for="online">
                        <input type="checkbox" name="online" id="online" value=""/>
                        使我保持登录状态</label>
                </div>
            </div>
            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <input name="" type="submit" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;"/>
                    <input name="" type="reset" class="btn btn-default radius size-L" value="&nbsp;取&nbsp;&nbsp;&nbsp;&nbsp;消&nbsp;"/>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="footer">Copyright 你的公司名称 by H-ui.admin v3.0</div>
<div th:include="public/layout::footer" th:remove="tag"></div>

</body>
<script>
    $(function(){
    $("#form-admin-login").validate({
        rules:{
            name: {
                required: true,
            },
            password:{
                required:true,
                minlength:6
            },
            code:{
                required:true,
                minlength:4
            }

        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            $(form).ajaxSubmit({
                type: 'post',
                url: $(form).attr("action") ,
                dataType:'json',
                success: function(data){
                    console.log(data);
                    if(data.code==0){
                        layer.msg(data.msg,{icon:1,time:3000},function () {
                            location.href="/";
                        });
                    }else {
                        layer.msg(data.msg,{icon:1,time:3000});
                    }


                },
                error: function(XmlHttpRequest, textStatus, errorThrown){
                    layer.msg('网络请求失败，请检查!',{icon:1,time:3000});
                }
            });


        }
    });
    });
</script>
</html>